#include "stdafx.h"
#include "CppUnitTest.h"

#include "MySolver/MySolver.h"

#include "SnakeAssert.h"
#include "../SnakeLib/Problem.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace MySolverTests
  {		
  TEST_CLASS(MySolverSuite)
    {
    public:

      /*TEST_METHOD(Should_When_)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "|> |"
          "+--+";
        EDirection expected = UP;

        // Act, Assert
        snake::Assert::Solve(board, MySolver(), expected);
        }*/

      TEST_METHOD(Should_Be_Up_When_HeadUp)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "|^ |"
          "+--+";
        snake::EDirection expected = snake::UP;

        // Act, Assert
        snake::Assert::GetCurrentDirection(board, MySolver(), expected);
        }

      TEST_METHOD(Should_Be_PositionOfHead_When_)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "|^ |"
          "+--+";
        std::pair<int, int> expected = std::make_pair(2, 1);

        // Act, Assert
        snake::Assert::GetHeadPosition(board, MySolver(), expected);

        // Arrange
        board =           
          "+--+"
          "|!>|"
          "|  |"
          "+--+";
        expected = std::make_pair(1, 2);

        // Act, Assert
        snake::Assert::GetHeadPosition(board, MySolver(), expected);
        }

      TEST_METHOD(Should_BeTrue_When_Crashing)
        {
        // Arrange
        auto board =           
          "+--+"
          "|! |"
          "| >|"
          "+--+";
        bool expected = true;

        // Act, Assert
        snake::Assert::CheckForCrash(board, MySolver(), expected);
        }

      TEST_METHOD(Should_BeDirection_When_ClosestsFoodInTheDirection)
        {
        // Arrange
        auto board =           
          "+--------+"
          "|!       |"
          "|        |"
          "|        |"
          "|        |"
          "|        |"
          "|        |"
          "|        |"
          "|   !v  !|"
          "+--------+";
        snake::EDirection expected = snake::LEFT;

        // Act, Assert
        snake::Assert::Solve(board, MySolver(), expected);

        // Arrange
        board =           
          "+--------+"
          "|!       |"
          "|        |"
          "|        |"
          "|    !   |"
          "|    v   |"
          "|        |"
          "|        |"
          "|    !   |"
          "+--------+";
        expected = snake::UP;

        // Act, Assert
        snake::Assert::Solve(board, MySolver(), expected);
        }
    };
  }